﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1._3DStructurePoint
{
    static class PathStorage
    {
        public static void savePath(Path path)
        {
            using (StreamWriter writer = new StreamWriter(@"../../PointPaths.txt"))
            {
                foreach (Point3D coords in path.PathOfPts)
                {
                    writer.WriteLine(String.Format("{0},{1},{2}", coords.CoordX, coords.CoordY, coords.CoordZ));
                }
            }
        }

        public static Path LoadPath()
        {
            Path loadPath = new Path();
           // List<Point3D> pathsLoaded = new List<Point3D>();
            using (StreamReader reader = new StreamReader(@"../../PointPaths.txt"))
            {
                string line = reader.ReadLine();
                while (line != null)
                {
                  //  if (line != "-")
                   // {
                        Point3D Loadedpoint = new Point3D();
                        string[] points = line.Split(',');
                        Loadedpoint.CoordX = int.Parse(points[0]);
                        Loadedpoint.CoordY = int.Parse(points[1]);
                        Loadedpoint.CoordZ = int.Parse(points[2]);
                       // loadPath.AddPoint(Loadedpoint);
                   // }
                   // else
                   // {
                        loadPath.AddPoint(Loadedpoint);
                        //pathsLoaded.Add(Loadedpoint);
                       // loadPath = new Path();
                  //  }
                    line = reader.ReadLine();
                }
            } return loadPath;
        }

    }
}
